package com.hanhai.zrb.backend.admin.dao.mybatis;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import com.hanhai.zrb.api.biz.dao.mybatis.base.BaseMapper;

public interface RolePrivilegeDao extends BaseMapper {

	@Insert("insert into role_privilege(role_id,acl) values (#{role_id},#{acl})")
	void add(Map<String, Object> params);

	@Delete("delete from role_privilege where role_id=#{roleId}")
	void deleteByRole(Integer roleId);

	@Delete("delete from role_privilege where acl=#{privilegeAcl}")
	void deleteByPrivilege(Integer privilegeAcl);

	@Select("select rp.*,p.name,p.acl from role_privilege rp left join privilege p on p.acl=rp.acl where role_id=#{id}")
	List<Map<String, Object>> listByRole(Integer id);

	@Select("select * from role_privilege where acl = #{acl}")
	List<Map<String, Object>> listByPrivilege(Integer acl);
}
